package com.rt.code.utils.page;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;

import java.io.Serializable;

/**
 * Created by wxy on 2020/2/2.
 */
@ApiModel(description = "分页传输对象")
public class PageDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "指定排序列名[id]")
    @ApiParam(defaultValue = "id")
    private String sortColumn;

    @ApiModelProperty(value = "asc=false")
    @ApiParam(defaultValue = "false")
    private boolean asc;

    @ApiModelProperty(value = "当前页码")
    @ApiParam(defaultValue = "1")
    private int pageCurrent;

    @ApiModelProperty(value = "每页记录数")
    @ApiParam(defaultValue = "10")
    private int pageSize;

    @ApiModelProperty(value = "pageIndex=pageCurrent*pageSize")
    @ApiParam(defaultValue = "0")
    private int pageIndex;

    @Deprecated
    private String sortOrder;

    public boolean getCondition(){
        if(sortColumn==null || "".equalsIgnoreCase(sortColumn)){
            return false;
        }
        return true;
    }

    public String getSortOrder() {
        if(asc)sortOrder="asc";
        else sortOrder="desc";
        return sortOrder;
    }

    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }

    public int getPageIndex() {
        return pageIndex=pageCurrent*pageSize;
    }



    public boolean isAsc() {
        return asc;
    }

    public void setAsc(boolean asc) {
        this.asc = asc;
    }



    public String getSortColumn() {
        return sortColumn;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
    public void setSortColumn(String sortColumn) {
        this.sortColumn = sortColumn;
    }

    public int getPageCurrent() {
        return pageCurrent;
    }

    public void setPageCurrent(int pageCurrent) {
        this.pageCurrent = pageCurrent;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }


}
